﻿<%@ Page Language="C#" AutoEventWireup="true" Inherits="Message_Maintain" CodeFile="Message_Maintain.aspx.cs" MasterPageFile="~/MasterPage.master" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <title>消息维护</title> 
     
  
     
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
        <script type="text/javascript">
            /*  
            将Date/String类型,解析为String类型.  
            传入String类型,则先解析为Date类型  
            不正确的Date,返回 ''  
            如果时间部分为0,则忽略,只返回日期部分.  
            */
            function formatDate(v) {
                if (v instanceof Date) {
                    var y = v.getFullYear();
                    var m = v.getMonth() + 1;
                    var d = v.getDate();
                    var h = v.getHours();
                    var i = v.getMinutes();
                    var s = v.getSeconds();
                    var ms = v.getMilliseconds();
                    if (ms > 0)
                        return y + '-' + m + '-' + d + ' ' + h + ':' + i + ':' + s
						+ '.' + ms;
                    if (h > 0 || i > 0 || s > 0)
                        return y + '-' + m + '-' + d + ' ' + h + ':' + i + ':' + s;
                    return y + '-' + m + '-' + d;
                }
                return '';
            }

            $(function () {
                $('#<%=txtStartTime.ClientID %>').datebox({
                    currentText: '今天',
                    closeText: '关闭',
                    disabled: false,
                    required: true,
                    missingMessage: '必填',
                    formatter: formatDate
                });
            });
            $(function () {
                $('#<%=txtEndTime.ClientID %>').datebox({
                    currentText: '今天',
                    closeText: '关闭',
                    disabled: false,
                    required: true,
                    missingMessage: '必填',
                    formatter: formatDate
                });
            });
            function Preview() {

                $get('pic').filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src =$get('<%=FileUpload1.ClientID %>').value;      
               
            }

            function checkDate() {

                Page_ClientValidate();//验证服务器控件是否通过

                var txtStartTime = $('#<%=txtStartTime.ClientID %>').datebox('getValue');
                var txtEndTime = $('#<%=txtEndTime.ClientID %>').datebox('getValue');
                if (txtStartTime == "") {
                    alert("请选择开始日期");
                    return false;
                }
                if (txtEndTime == "") {
                    alert("请选择结束日期");
                    return false;
                }
                
                if (dateCompare(txtStartTime, txtEndTime) == 1) {
                    alert('结束日期不能小于开始日期');
                    return false;
                }


               return true;
           }

           function dateCompare(date1, date2) {
               date1 = date1.replace(/\-/gi, "/");
               date2 = date2.replace(/\-/gi, "/");
               var time1 = new Date(date1).getTime();
               var time2 = new Date(date2).getTime();
             
               if (time1 > time2) {
                   return 1;
               } else if (time1 == time2) {
                   return 2;
               } else {
                   return 3;
               }
           }


</script>
         
            <table id="wsd_inputtable"   >
                <tr >
                    <td colspan="5" class="tabletitle">
                        <font color="red" size="2"><b><asp:Literal
                            ID="Literal4" runat="server" Text="<%$resources:language,lbl_Required %>"></asp:Literal>
                    </td>
                  
                </tr>     
                <tr>
                    <td class="tablefield"">
                     <font color="red">*</font>主题:</td>
                    <td style=" width:20%;" >
                        <asp:TextBox runat="server"  MaxLength="40" Width="150"
                            ID="txtTopic" class="default"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" ControlToValidate="txtTopic"
                              runat="server" ErrorMessage="<%$resources:language,lbl_TheRequired %>"></asp:RequiredFieldValidator>
                    </td>
                    <td class="tablefield"  >
                        消息类型:</td>
                    <td nowrap="nowrap" >
                    <asp:DropDownList runat="server" ID="ddlMessageLevel" Width="150">
                    </asp:DropDownList>
                        </td>
                        <td rowspan="5"
                </tr>图片预览
                            <div id="pic"  style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale);width:109px; height:162px; border:1px solid black;"></div> 
                            <tr>
                    <td class="tablefield">
                        <font color="red">*</font>发布日期:</td>
                    <td nowrap="nowrap"  >
                        <asp:TextBox runat="server" Width="150" ID="txtStartTime" MaxLength="20" 
                            class="default"></asp:TextBox>
                        </td>
                        <td nowrap="nowrap"  class="tablefield">
                            <font color="red">*</font>截止日期:</td>
                        <td nowrap="nowrap"  >
                        <asp:TextBox runat="server" Width="150" ID="txtEndTime" MaxLength="20" 
                                class="default"></asp:TextBox>
                        </td>
                </tr>
                <tr>
                    <td class="tablefield">
                         <font color="red">*</font>接收人:</td>
                    <td nowrap="nowrap">
                        <asp:TextBox ID="txtReceiver" runat="server" Width="150" onkeydown="alert('请选择部门');return false;"
                          class="default"  ></asp:TextBox>
                        <img src="../Resources/Images/search.png" alt="查找" style="cursor: pointer;" onclick="openPopup('../System/PopupOrganizationUser.aspx?NameControlId=<%=txtReceiver.ClientID %>&ValueControlId=<%= Hidden1.ClientID %>&txtCountID=<%=txtCount.ClientID %>&SelectType=multi','','300','500');" /><asp:RequiredFieldValidator 
                            ID="RequiredFieldValidator3" runat="server" ControlToValidate="txtReceiver"
                              ErrorMessage="接收人不能为空!"></asp:RequiredFieldValidator>
                    </td>
                    <td class="tablefield"  >
                        人数:</td>
                    <td nowrap="nowrap">
                        
                        <input type="text" runat="server" id="txtCount" readonly="readonly" class="default" />
                    </td>
                </tr>
                <tr>
                    <td class="tablefield">
                         有效:</td>
                    <td nowrap="nowrap">
                        <asp:CheckBox ID="chxActive" runat="server" Checked="true" />
                    </td>
                    <td nowrap="nowrap" class="tablefield">
                        附件:</td>
                    <td nowrap="nowrap">
                                   
                        <asp:FileUpload ID="FileUpload1" runat="server" Width="150px" onpropertychange ="Preview()"    />

                    </td>
                     
                </tr>   
                <tr>
                <td class="tablefield"> <font color="red">*</font>消息内容:</td>
                <td colspan="3">
                    <asp:TextBox runat="server" ID="txtContent"  
                            class="default" TextMode="MultiLine" Height="82px" Width="94%"  ></asp:TextBox>
                             <asp:RequiredFieldValidator ID="RequiredFieldValidator2" ControlToValidate="txtContent"
                              runat="server" ErrorMessage="*"></asp:RequiredFieldValidator>
                            </td>
                </tr>
            </table>
      
        
                                            
     
        <asp:EntityDataSource ID="EntityDataSource1" runat="server" 
            ConnectionString="name=JumptonSFAEntities" 
            DefaultContainerName="JumptonSFAEntities" 
            EnableFlattening="False" EntitySetName="MESSAGEs" EnableDelete="True" 
            EnableInsert="True" EnableUpdate="True">
        </asp:EntityDataSource>
  
        <table id="wsd_inputtable">
            <tr>
                <td width="100%" class="tabletitle">
                    <asp:Literal ID="Literal1" runat="server" Text="<%$resources:language,lbl_Operation_Area %>"></asp:Literal>
              
                </td>
            </tr>
            <tr>
                <td class="buttonarea">
                        <asp:Button ID="btnSubmit" runat="server"  Text="提 交" CssClass="wsd_button2" OnClick="btnSubmit_Click" OnClientClick="return checkDate();" />&nbsp;&nbsp;
                        
                            <input type="button" value="返 回" onclick="window.location.href='Message_Manage.aspx';" Class="wsd_button2" />
                </td>
            </tr>
        </table>
         
    <asp:HiddenField ID="hid_receiver" runat="server" />
    
     <input id="txtHidOrg" type="hidden" runat="server" />
                      <input id="Hidden1" type="hidden" runat="server" />
                       <input type="hidden" id="Status" runat="server" />

	</div>
</asp:Content>
